import { auth } from '@/config/env'
import request from '@/utils/axios'

export const getCaptcha = () => {
  return request({
    url: auth + '/captcha',
    method: 'get',
  });
}

export const login = form => {
  return request({
    headers: {
      'Captcha-Key': form.captchaKey,
    },
    url: auth + '/login',
    method: 'post',
    data: form.data
  });
}

export const logout = () => {
  return request({
    url: auth + '/logout',
    method: 'get',
  });
}

export const refreshToken = param => {
  return request({
    url: auth + '/token/refresh?refreshToken=' + param,
    method: 'get',
  });
}

export const register = form => {
  return request({
    headers: {
      'Captcha-Key': form.captchaKey,
    },
    url: auth + '/register',
    method: 'post',
    data: form.data
  });
}